home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / doors_2 / useron33.zip / DOIT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-02  |  3KB  |  121 lines

  1. {-----------------------------------------------------------------------------|
  2.  
  3.  DoIt 1.1
  4.  Gerhard Hoogterp (2:283/1.2 27:4331/106 HOOGTERPG@HENUT5.BITNET)
  5.  04 Nov 1991
  6.  
  7.  Dumped in the Public domain, do with it whatever you like. Note however
  8.  that the usage of this unit is completely on your own risk!
  9.  
  10.  Oh, don't make the DoString longer than 70 characters. UserOn.Exe will chop
  11.  them off....
  12.  
  13.  1.1:
  14.   Added the DoPath. under RA 1.10 UserOn will use the Semafore directory.
  15.   Since this path is only known in the Config.Ra, I can't find it in this
  16.   little demo unit. Default, the DoPath is the same as the system path.
  17.   The directory the RA environment variable points to. Put the Semafore Path
  18.   inside this variable when you want to use it under RA 1.10.
  19.  
  20. |-----------------------------------------------------------------------------}
  21.  
  22.  
  23. Unit DoIt;
  24. Interface
  25. Uses Dos;
  26.  
  27. Type  DoString  = String[70];
  28.  
  29. Var   DoPath    : PathStr;
  30.  
  31.  
  32. {------------------------------------------------------------------------|
  33.   Fill DoingWhat with the string you want to appear in the UserOn door
  34. |------------------------------------------------------------------------}
  35.  
  36. Const DoingWhat : DoString = 'Working with a LiveSystems door.';
  37.       DefaultStr: DoString = 'In a door/external utility';
  38.  
  39. {------------------------------------------------------------------------|
  40.   GrabInfo Lookes for the USERDOES.<NodeNr> file and returns it's
  41.   contents when found. If not found the default string is returned.
  42. |------------------------------------------------------------------------}
  43.  
  44. Function GrabInfo(LineNr : Byte):DoString;
  45.  
  46. {------------------------------------------------------------------------|
  47.   SetDoingInfo writes a file USERDOES.<NodeNr> with the DoingWhat string
  48. |------------------------------------------------------------------------}
  49.  
  50. Procedure SetDoingInfo(LineNr : Byte);
  51.  
  52. {------------------------------------------------------------------------|
  53.  ClearDoingInfo erases the USERDOES.<NodeNr>
  54. |------------------------------------------------------------------------}
  55.  
  56. Procedure ClearDoingInfo(LineNr : Byte);
  57.  
  58.  
  59. Implementation
  60.  
  61. Type Str2 = String[2];
  62.  
  63.  
  64. Function S(Number : Byte;Size:Byte):Str2;
  65. Var HStr : Str2;
  66. Begin
  67. Str(Number:Size,HStr);
  68. S:=HStr;
  69. End;
  70.  
  71. Procedure CompletePath(Var Path : String);
  72. Begin
  73. Path:=FExpand(Path);
  74. If (Path[Length(Path)]<>'\') And
  75.    (Path[Length(Path)]<>':')
  76.    Then Path:=Path+'\';
  77. End;
  78.  
  79. Function GrabInfo(LineNr : Byte):DoString;
  80. Var DoIt : Text;
  81.     Line : DoString;
  82. Begin
  83. FileMode:=64; { ReadOnly/ShareDenyNone }
  84.  
  85. Assign(DoIt,DoPath+'UserDoes.'+S(LineNr,0));
  86. Reset(DoIt);
  87. If IoResult<>0
  88.    Then Begin
  89.         GrabInfo:=DefaultStr;
  90.         Exit;
  91.         End;
  92. ReadLn(DoIt,Line);
  93. Close(DoIt);
  94. If Length(Line)>70
  95.    Then Line[0]:=#70;
  96. GrabInfo:=Line;
  97. End;
  98.  
  99. Procedure SetDoingInfo(LineNr : Byte);
  100. Var DoIt : Text;
  101. Begin
  102. FileMode:=49;  { WriteOnly/ShareDenyRead }
  103. Assign(DoIt,DoPath+'UserDoes.'+S(LineNr,0));
  104. Rewrite(DoIt);
  105. WriteLn(DoIt,DoingWhat);
  106. Close(DoIt);
  107. End;
  108.  
  109. Procedure ClearDoingInfo(LineNr : Byte);
  110. Var DoIt : File;
  111. Begin
  112. FileMode:=17; { WriteOnly/ShareDenyAll }
  113. Assign(DoIt,DoPath+'UserDoes.'+S(LineNr,0));
  114. Erase(DoIt);
  115. End;
  116.  
  117. Begin
  118. DoPath:=GetEnv('RA');
  119. CompletePath(RAPath);
  120. End.
  121.